Initial setup: Add AWS CDK constructs library with comprehensive features#1
Merged
Conversation
- Add LambdaFunctionConstruct with IAM roles, policies, and logging - Implement OpenTelemetry integration with AWS OTEL Collector layer - Add versioning and alias support for Lambda deployments - Fix CS0618 warning by replacing deprecated LogRetention with LogGroup - Create comprehensive test suite with xUnit v3 and AutoFixture - Add detailed README with installation, usage examples, and documentation - Update project configuration for NuGet packaging 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Renamed includeOtelLayer1 and includePermissions1 to match the constructor parameter names for better code clarity and readability. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…ation - Add assertions to verify logs:CreateLogStream, logs:CreateLogGroup, logs:TagResource actions - Add assertion to verify logs:PutLogEvents action in separate policy statement - Verify correct ARN resources for both log group and log stream levels - Test now properly validates the CloudWatch Logs permissions as intended 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…sabled test - Verify TracingConfig property is not present when OTEL layer is disabled - Verify Layers property is not present when OTEL layer is disabled - Use Match.Not() with Match.AnyValue() to assert properties are absent - Test now properly validates the disabled tracing behavior as intended 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Use discard pattern (_) for unused construct variables - Simplify permission count logic with early return - Remove unnecessary variable assignments for cleaner code 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR bootstraps a new .NET AWS CDK constructs library with end-to-end Lambda function support and adds a full test suite.
- Introduces
LambdaFunctionConstructwith IAM, logging, versioning, and optional OpenTelemetry integration - Defines configuration models (
LambdaFunctionConstructProps,LambdaPermission) and test utilities with AutoFixture - Adds comprehensive xUnit v3 tests, project/solution configuration, CI workflows, and detailed README
Reviewed Changes
Copilot reviewed 17 out of 20 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/LayeredCraft.Cdk.Constructs.Tests/xunit.runner.json | Add xUnit runner schema config |
| test/LayeredCraft.Cdk.Constructs.Tests/TestKit/Customizations/LambdaFunctionConstructCustomization.cs | Define AutoFixture customization for Lambda props |
| test/LayeredCraft.Cdk.Constructs.Tests/TestKit/Attributes/LambdaFunctionConstructAutoDataAttribute.cs | Create custom AutoData attribute for parameterized tests |
| test/LayeredCraft.Cdk.Constructs.Tests/TestKit/Attributes/BaseFixtureFactory.cs | Provide base AutoFixture setup with recursion and NSubstitute |
| test/LayeredCraft.Cdk.Constructs.Tests/LayeredCraft.Cdk.Constructs.Tests.csproj | Configure test project references and global usings |
| test/LayeredCraft.Cdk.Constructs.Tests/Constructs/LambdaFunctionConstructTests.cs | Add unit tests covering all construct behaviors |
| src/LayeredCraft.Cdk.Constructs/Models/LambdaPermission.cs | Define model for Lambda invocation permissions |
| src/LayeredCraft.Cdk.Constructs/Models/LambdaFunctionConstructProps.cs | Define props interface and record for Lambda construct |
| src/LayeredCraft.Cdk.Constructs/LayeredCraft.Cdk.Constructs.csproj | Configure library project metadata and dependencies |
| src/LayeredCraft.Cdk.Constructs/Constructs/LambdaFunctionConstruct.cs | Implement core Lambda CDK construct (IAM, logs, OTEL, versioning) |
| README.md | Add installation, usage examples, API reference, and project structure |
| LayeredCraft.Cdk.Constructs.sln | Initialize solution including src and test projects |
| Directory.Build.props | Define package defaults, metadata, and source linking |
| CLAUDE.md | Add guidance for Claude Code generation |
| .github/workflows/pr-build.yaml | Add PR validation workflow |
| .github/workflows/build.yaml | Add main build and packaging workflow |
| .github/dependabot.yml | Configure Dependabot for NuGet updates |
Comments suppressed due to low confidence (3)
test/LayeredCraft.Cdk.Constructs.Tests/TestKit/Attributes/BaseFixtureFactory.cs:1
- The BaseFixtureFactory references types like Fixture, IFixture, ThrowingRecursionBehavior, and OmitOnRecursionBehavior from AutoFixture but does not include 'using AutoFixture;'. Add the missing using directive to avoid compile errors.
using AutoFixture.AutoNSubstitute;
src/LayeredCraft.Cdk.Constructs/Models/LambdaFunctionConstructProps.cs:27
- Initializing a List with '[]' will not compile. Replace with a proper List initializer, e.g., 'new List()'.
public List<LambdaPermission> Permissions { get; set; } = [];
test/LayeredCraft.Cdk.Constructs.Tests/TestKit/Customizations/LambdaFunctionConstructCustomization.cs:36
- You’re assigning an array via '[]' to a List property, causing a type mismatch. Use 'new List { fixture.Create() }' or another List initializer.
.With(props => props.Permissions, includePermissions
ncipollina
added a commit
that referenced
this pull request
Jul 8, 2025
- Replace array initializations with modern C# collection expressions ([]) - Use discard operator (_) for unused construct variables in tests - Move DynamoDB constructs from Constructs/ to root folder - Fix 8 failing unit tests related to DynamoDB template assertions - Add comprehensive DynamoDB construct testing support - Update CloudFormation output assertions to use export names instead of logical IDs - Implement proper AttributeType mapping for DynamoDB assertions Fixes #1 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
ncipollina
added a commit
that referenced
this pull request
Jul 8, 2025
) * Update codebase to use collection expressions and fix failing tests - Replace array initializations with modern C# collection expressions ([]) - Use discard operator (_) for unused construct variables in tests - Move DynamoDB constructs from Constructs/ to root folder - Fix 8 failing unit tests related to DynamoDB template assertions - Add comprehensive DynamoDB construct testing support - Update CloudFormation output assertions to use export names instead of logical IDs - Implement proper AttributeType mapping for DynamoDB assertions Fixes #1 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix README documentation to use correct API types and collection expressions - Replace AttributeDefinition with Attribute in DynamoDB examples - Update array initializations to use collection expressions - Ensure documentation matches actual construct API Addresses GitHub Copilot feedback on API consistency 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Add default partition key to CreateDynamoDbTablePropsBuilder and comprehensive unit tests - Set default partition key "pk" with STRING type in CreateDynamoDbTablePropsBuilder since it's required for DynamoDB table creation - Add comprehensive unit tests to verify default partition key is set correctly - Add tests to verify customization capabilities and valid table creation - Update documentation to explain the default partition key requirement Addresses GitHub Copilot feedback about missing required partition key 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Add comprehensive test coverage for DynamoDB testing helpers to achieve 100% coverage This commit adds 46 comprehensive unit tests covering both DynamoDB testing helper classes: **DynamoDbTableConstructAssertions (100% coverage):** - ShouldHaveDynamoTable with various scenarios - ShouldHavePartitionKey with all AttributeTypes (STRING, NUMBER, BINARY) - ShouldHaveSortKey with all AttributeTypes (STRING, NUMBER, BINARY) - ShouldHaveGlobalSecondaryIndex with GSI validation - ShouldHaveTableStream with all StreamViewTypes (NEW_IMAGE, OLD_IMAGE, NEW_AND_OLD_IMAGES, KEYS_ONLY) - ShouldHaveTimeToLiveAttribute with TTL validation - ShouldHaveTableOutputs with case normalization and comprehensive error scenarios - ShouldHaveGlobalSecondaryIndexCount with zero, single, and multiple GSI scenarios **DynamoDbTableConstructPropsBuilder (100% coverage):** - Constructor defaults validation - All With* methods (table name, partition key, sort key, removal policy, billing mode) - GSI configuration with both partition-only and partition+sort key scenarios - Stream configuration with WithStream and WithoutStream - TTL configuration with WithTimeToLiveAttribute and WithoutTimeToLiveAttribute - Scenario-based configurations: ForUserTable, ForSessionTable, ForEventSourcing - Method chaining and value overwriting behavior - Full integration test creating actual DynamoDB construct **Coverage highlights:** - Tests all code paths including error conditions - Validates all AttributeTypes and StreamViewTypes - Tests case normalization and export name validation - Comprehensive error message validation - Integration tests with actual CDK constructs - Tests both positive and negative scenarios Total test count increased from 95 to 141 tests (46 new tests added) All tests pass with 100% coverage on both DynamoDB testing helper classes 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Simplify CreateDynamoDbTablePropsBuilder by removing redundant default calls Address GitHub Copilot feedback to reduce redundancy in CreateDynamoDbTablePropsBuilder: - Remove explicit WithTableName("test-table") - builder already defaults to "test-table" - Remove explicit WithBillingMode(PAY_PER_REQUEST) - builder already defaults to PAY_PER_REQUEST - Remove explicit WithRemovalPolicy(DESTROY) - builder already defaults to DESTROY - Keep only WithPartitionKey("pk") since partition key defaults to null but is required for DynamoDB This change: - Reduces redundancy by relying on builder's built-in defaults - Focuses only on the essential override (partition key) - Maintains same functionality with cleaner, more maintainable code - Updates documentation to clarify the builder's built-in defaults All 141 tests continue to pass, confirming no functional changes. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Key Features
Test plan
dotnet build)dotnet run --project test/LayeredCraft.Cdk.Constructs.Tests/ --framework net8.0)🤖 Generated with Claude Code